package cn.codergege.demo.controller

import cn.codergege.demo.service.PersonService
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.http.MediaType
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.context.junit.jupiter.SpringExtension
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.content
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status

@ExtendWith(SpringExtension::class)
@WebMvcTest(HelloController::class)
@ActiveProfiles("test")
class HelloControllerTest {
    @Autowired
    private lateinit var mvc: MockMvc
    @MockBean
    lateinit var personService: PersonService

    @Test fun hello() {
        this.mvc.perform(get("/hello")
//            .accept(MediaType.TEXT_PLAIN))
            .accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk)
//            .andExpect(content().string("Hello world!"))
    }
}
